package Models;

import DB.DBCar;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

public class Car implements DB.RowInterface
{
	private int carNo;
	private String licensePlate = "";

	public Car ()
	{}

	public void importData(ResultSet data) throws SQLException
	{
		this.setCarNo(data.getInt("carNo"));
		this.setLicensePlate(data.getString("licensePlate"));
	}

	public HashMap exportData()
	{
		HashMap data = new HashMap();
		data.put("licensePlate", getLicensePlate());
		return data;
	}

	public void setData(String licensePlateS) throws EmptyValueException
	{
		if(!licensePlateS.equals(""))
		{
			this.setLicensePlate(licensePlateS);
		}
		else
		{
			throw new EmptyValueException();
		}
	}

	public void refreshData()
	{
		Car car = new DBCar().fetchByNo(getCarNo());
		this.setLicensePlate(car.getLicensePlate());
	}

	public static String[] getSearchColumns()
	{
		return new String[] { "carNo", "licensePlate" };
	}

	public int getCarNo()
	{
		return carNo;
	}

	public String getLicensePlate()
	{
		return licensePlate;
	}

	public void setCarNo(int carNo)
	{
		this.carNo = carNo;
	}

	public void setLicensePlate(String licensePlate)
	{
		this.licensePlate = licensePlate;
	}
}
